import * as React from 'react';
import { Spin } from 'antd';
import './Loading.scss';
import {openLoading, closeLoading} from 'src/app/redux/actions/Loading.actions';
import { connect } from 'src/app/redux/connect/Connect';
interface Props extends React.Props<any> {
  tip?: string;
  delay?: number;
  size?: any;
  Loading?: any;
  open?: boolean
}
@connect(state => state, {openLoading, closeLoading})
export class Loading extends React.PureComponent<Props, any> {
  refs: any
  public static defaultProps: Props = {
    tip: '加载中。。。',
    delay: 300,
    size: 'large',
    open: false
  }
  render() {
    const { tip, delay, size } = this.props;
    return this.props.Loading.open ? (
      <div ref={ele => this.refs = ele}  className='loading'>
        <div className='loading-content'>
          <Spin className='spin' tip={tip} delay={delay} size={size} />
        </div>
      </div>
    ) : null
  }
}
